﻿Public Class frmSetPass
    Public Sub gan(ByVal MaNV As String)
        Me.lbMaNV.Text = MaNV
    End Sub
    Dim them As Boolean = False
    Public Sub trangthai(ByVal them As Boolean)
        Me.them = them
    End Sub
    'Dim provider As New DataProvider()
    Dim connect As New connect()
    Private Sub btnUpdate_Click(sender As System.Object, e As System.EventArgs) Handles btnUpdate.Click
        If (txtRePass.Text <> txtPass.Text) Then
            MessageBox.Show("Mật khẩu không trùng khớp")
            txtRePass.Focus()
            Return
        Else
            If (them = True) Then
                Dim pass As String = txtPass.Text
                frmQuanLy.UcqlNhanVien1.datpass(pass)
                them = False
                Me.Close()

            Else
                Dim sql = "update NHANVIEN set MATKHAU='" + lbMaNV.Text.Trim() + "' where MANV='" + lbMaNV.Text + "'"
                connect.ExecSql(sql)
                MessageBox.Show("Đặt mật khẩu cho nhân viên " + lbMaNV.Text + " thành công!")
                Me.Close()
            End If
        End If
    End Sub

    Private Sub btnClose_Click(sender As System.Object, e As System.EventArgs) Handles btnClose.Click
        Me.Close()
    End Sub

    Private Sub frmSetPass_KeyDown(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
        If (e.KeyCode = Keys.Enter) Then
            btnUpdate.PerformClick()
        End If
    End Sub

End Class